package packet1;
import java.util.Scanner;

public class test1 {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int m = sc.nextInt();
            int n = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            double[] core = new double[m];
            int a = 0;
            double b = 0;
            for (int i = 0; i < m; i++) {
                core[i] = 10;
            }
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == ' ')
                    continue;
                if (s.charAt(i) == 'A')
                {
                    for (int j = 0; j < m; j++) {
                        if(core[j] != 0)
                        {
                            core[j] -= 2.5;
                            a = j + 1;
                            b = 4 - core[j] / 2.5;
                            break;
                        }
                    }
                }
                if (s.charAt(i) == 'B')
                {
                    for (int j = 0; j < m; j++) {
                        if(core[j] == 10)
                        {
                            core[j] = 0;
                            a = j + 1;
                            b = 1;
                            break;
                        }
                    }
                }

            }
            System.out.println(a);
            int c = (int)b;
            System.out.println(c);
        }

}
